package com.itheima.dao;


import com.itheima.pojo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;


/**
 * 预约业务  持久层
 */
@Mapper
public interface OrderDao {

    Order findById(Long id);

    /**
     * 根据会员id和套餐id查询预约数据
     * @param id
     * @param setmealId
     * @return
     */
    @Select("select * from t_order where member_id = #{id} and setmeal_id = #{setmealId}")
    Order getByMemberIdAndSetmealId(Integer id, Integer setmealId);

    /**
     * 保存预约数据
     * @param newOrder
     */
    @Insert("insert into t_order(member_id, orderDate, orderType, orderStatus, setmeal_id) VALUES " +
            "(#{memberId},#{orderDate},#{orderType},#{orderStatus},#{setmealId})")
    void saveOrder(Order newOrder);
}
